//
// Unihan Input Method
//
// Copyright © 2002-2007 Sun Wah Linux Ltd.
//
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
// USA
//
// $Id: punctuation.c 757 2007-05-10 08:19:31Z roger $
//

/* file : punctuation.c */

#include <string.h>

#include "punctuation.h"

static const PunctuationList FWPuncList[] = {
	{ ',',  "，" },
	{ '.',  "。" },
	{ '\\', "、" },
	{ '`',  "｀" },
	{ '\'', "＇" },
        { ' ',  "　" },
        { '[',  "【" },
        { ']',  "】" },
        { '<',  "《" },
        { '>',  "》" },
        { '!',  "！" },
        { '"',  "＂" },
        { '#',  "＃" },
        { '$',  "＄" },
        { '%',  "％" },
        { '&',  "＆" },
        { '(',  "（" },
        { ')',  "）" },
        { '*',  "＊" },
        { '+',  "＋" },
        { '-',  "－" },
        { '/',  "／" },
        { '0',  "０" },
        { '1',  "１" },
        { '2',  "２" },
        { '3',  "３" },
        { '4',  "４" },
        { '5',  "５" },
        { '6',  "６" },
        { '7',  "７" },
        { '8',  "８" },
        { '9',  "９" },
        { ':',  "：" },
        { ';',  "；" },
        { '=',  "＝" },
        { '?',  "？" },
        { '@',  "＠" },
        { '^',  "＾" },
        { '{',  "｛" },
        { '|',  "｜" },
        { '}',  "｝" },
        { '~',  "～" },
	{ '0', NULL }
};

static const PunctuationList CNPuncList[] = {
	{ ',',  "，" },
	{ '.',  "。" },
	{ '\\', "、" },
	{ '`',  "`" },
	{ '\'', "‘" },
        { ' ',  " " },
        { '[',  "[" },
        { ']',  "]" },
        { '<',  "《" },
        { '>',  "》" },
        { '!',  "！" },
        { '"',  "“”" },
        { '#',  "#" },
        { '$',  "￥" },
        { '%',  "%" },
        { '&',  "—" },
        { '(',  "（" },
        { ')',  "）" },
        { '*',  "*" },
        { '+',  "+" },
        { '-',  "-" },
        { '/',  "/" },
        { '0',  "0" },
        { '1',  "1" },
        { '2',  "2" },
        { '3',  "3" },
        { '4',  "4" },
        { '5',  "5" },
        { '6',  "6" },
        { '7',  "7" },
        { '8',  "8" },
        { '9',  "9" },
        { ':',  "：" },
        { ';',  "；" },
        { '=',  "=" },
        { '?',  "？" },
        { '@',  "·" },
        { '^',  "……" },
        { '{',  "{" },
        { '|',  "|" },
        { '}',  "}" },
        { '~',  "~" },
	{ '0', NULL }
};

int
is_punctuation(char c)
{
	int i = 0;

	while (FWPuncList[i].punc) {
		if (c == FWPuncList[i].key)
			return 1;
		i++;
	}
	return 0;
}

const char *
get_fw_punctuation(char c)
{
	int i = 0;

	while (FWPuncList[i].punc) {
		if (c == FWPuncList[i].key)
			return FWPuncList[i].punc;
		i++;
	}
	return NULL;
}

const char *
get_cn_punctuation(char c)
{
	int i = 0;

	while (CNPuncList[i].punc) {
		if (c == CNPuncList[i].key)
			return CNPuncList[i].punc;
		i++;
	}
	return NULL;
}

// vi:ts=4:nowrap:cin:expandtab
